import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from "path";
import Components from 'unplugin-vue-components/vite'
import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    Components({
      dirs: ['src/components'],

      // valid file extensions for components.
      extensions: ['vue'],
      resolvers: [AntDesignVueResolver()]
    })
  ],
  server: {
    proxy: {
      '/api': {
        // target: 'http://127.0.0.1:8081',
        target: 'http://124.221.177.11',
        // ws: true,
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '')
      }
    }
  },
  resolve: {
    alias: {
      "@": resolve(__dirname, "./src"),
      "@c": resolve(__dirname, "./src/components"),
    },
  },
  configureWebpack: {
    devtool: 'source-map'
  }
})
